package com.javajun.entity;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * @className: Enterprise
 * @description: 租户，表示企业，一个租户对有且只有一个租户管理员
 * @author: JavaJun
 * @date: 2018年10月29日
 */
@Entity
public class Enterprise {
    
    private Integer id;
    // 租户名字，即企业名字，长度50
    private String name;
    // 授权开始日期
    private Date startTime;
    // 授权结束日期
    private Date endTime;
    // 缴纳金额
    private Double payMoney;
    // 创建日期
    private Date creatDate;
    // 创建人
    private String creatUser;
    // 是否删除
    private Integer deleted;
    // 租户管理员
    private EnterpriseAdmin enterpriseAdmin;
    // 发票集合
    @JsonIgnore
    private List<Invoice> invoices;
    // 授权
    private Empower empower;
    // 用户
    @JsonIgnore
    private List<Customer> customers = new ArrayList<>();
    
    @Id
    @GeneratedValue
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    
    @Column(length=50)
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    
    public Double getPayMoney() {
        return payMoney;
    }
    public void setPayMoney(Double payMoney) {
        this.payMoney = payMoney;
    }
    @OneToOne(cascade=CascadeType.ALL)
    @NotFound(action=NotFoundAction.IGNORE)
    public EnterpriseAdmin getEnterpriseAdmin() {
        return enterpriseAdmin;
    }
    public void setEnterpriseAdmin(EnterpriseAdmin enterpriseAdmin) {
        this.enterpriseAdmin = enterpriseAdmin;
    }
    
    public String getCreatUser() {
        return creatUser;
    }
    public void setCreatUser(String creatUser) {
        this.creatUser = creatUser;
    }
    
    @Column(name="is_deleted")
    public Integer getDeleted() {
        return deleted;
    }
    public void setDeleted(Integer deleted) {
        this.deleted = deleted;
    }
    public Date getStartTime() {
        return startTime;
    }
    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }
    public Date getEndTime() {
        return endTime;
    }
    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }
    public Date getCreatDate() {
        return creatDate;
    }
    public void setCreatDate(Date creatDate) {
        this.creatDate = creatDate;
    }
    @OneToMany(mappedBy="enterprise")
    public List<Invoice> getInvoices() {
        return invoices;
    }
    public void setInvoices(List<Invoice> invoices) {
        this.invoices = invoices;
    }
    
    @ManyToOne(cascade=CascadeType.ALL)
    @NotFound(action=NotFoundAction.IGNORE)
    public Empower getEmpower() {
        return empower;
    }
    public void setEmpower(Empower empower) {
        this.empower = empower;
    }
    
    @OneToMany(mappedBy="enterprise")
    public List<Customer> getCustomers() {
        return customers;
    }
    public void setCustomers(List<Customer> customers) {
        this.customers = customers;
    }
    
}
